// pages/fillAddress/fillAddress.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    name:"",
    phone:"",
    company:"",
    companyPhone:"",
  },
  name:function(e){

      this.setData({
        name: e.detail.value
      })
    
  },
  phone:function(e){
    this.setData({
      phone:e.detail.value
    })
  },
  company:function(e){
    this.setData({
      company:e.detail.value
    })
  },
  companyPhone:function(e){
    this.setData({
      companyPhone:e.detail.value
    })
  },
// 保存数据
save:function(){
  var that=this;
  if (!(/^[\u4E00-\u9FA5A-Za-z]+$/.test(that.data.name))) {

    wx.showToast({

      title: '姓名有误',

      duration: 2000,

      icon: "none"

    })
  } else if (!(/^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\d{8}$/.test(that.data.phone))) {

    wx.showToast({

      title: '手机号码有误',

      duration: 2000,

      icon: "none"

    })

    }else{
    wx.setStorageSync("name", this.data.name);
    wx.setStorageSync("phone", this.data.phone);
    wx.setStorageSync("company", this.data.company);
    wx.setStorageSync("companyPhone", this.data.companyPhone);
    wx.navigateBack({
    });
    }
 
},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    console.log(options);
    if(options.name!=undefined){
      that.setData({
        name:options.name,
        phone:options.phone,
        company:options.companyName,
        companyPhone:options.companyPhone
      })
    }
    if (wx.getStorageSync("mes") != "") {
      that.setData({
        name: wx.getStorageSync("mes").name,
        phone: wx.getStorageSync("mes").phone
      })
    }

// wx.request({
//   url: 'http://192.168.0.106:8002/sendUser/findById',
//   method:"post",
//   data:{
//     sendUserId: 1,
//   },
//   success:function(res){
//     console.log(res)
//   }
// })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})